'use strict';
var y = Object.defineProperty;
var M = (o, t, e) =>
  t in o
    ? y(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e })
    : (o[t] = e);
var i = (o, t, e) => (M(o, typeof t != 'symbol' ? t + '' : t, e), e);
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const m = require('../../nodes/identity.cjs'),
  d = require('../../nodes/toJS.cjs'),
  l = require('../../nodes/YAMLMap.cjs'),
  g = require('../../nodes/YAMLSeq.cjs'),
  f = require('./pairs.cjs'),
  u = class u extends g.YAMLSeq {
    constructor() {
      super();
      i(this, 'add', l.YAMLMap.prototype.add.bind(this));
      i(this, 'delete', l.YAMLMap.prototype.delete.bind(this));
      i(this, 'get', l.YAMLMap.prototype.get.bind(this));
      i(this, 'has', l.YAMLMap.prototype.has.bind(this));
      i(this, 'set', l.YAMLMap.prototype.set.bind(this));
      this.tag = u.tag;
    }
    toJSON(e, s) {
      if (!s) return super.toJSON(e);
      const a = new Map();
      s != null && s.onCreate && s.onCreate(a);
      for (const n of this.items) {
        let r, c;
        if (
          (m.isPair(n)
            ? ((r = d.toJS(n.key, '', s)), (c = d.toJS(n.value, r, s)))
            : (r = d.toJS(n, '', s)),
          a.has(r))
        )
          throw new Error('Ordered maps must not include duplicate keys');
        a.set(r, c);
      }
      return a;
    }
    static from(e, s, a) {
      const n = f.createPairs(e, s, a),
        r = new this();
      return (r.items = n.items), r;
    }
  };
i(u, 'tag', 'tag:yaml.org,2002:omap');
let p = u;
const h = {
  collection: 'seq',
  identify: o => o instanceof Map,
  nodeClass: p,
  default: !1,
  tag: 'tag:yaml.org,2002:omap',
  resolve(o, t) {
    const e = f.resolvePairs(o, t),
      s = [];
    for (const { key: a } of e.items)
      m.isScalar(a) &&
        (s.includes(a.value)
          ? t(`Ordered maps must not include duplicate keys: ${a.value}`)
          : s.push(a.value));
    return Object.assign(new p(), e);
  },
  createNode: (o, t, e) => p.from(o, t, e),
};
exports.YAMLOMap = p;
exports.omap = h;
